package com.lxl.bt.adapter;

import android.os.Parcelable;
import android.util.Log;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.lxl.bt.fragment.MessageChildFragment;

import java.util.List;


public class MessageBootFragmentAdapter extends FragmentStatePagerAdapter {
    private static String TAG = "SelectionFragmentAdapter";
    private List<String> promoCategories;
    public MessageBootFragmentAdapter(FragmentManager fm) {
        super(fm);
    }

    public MessageBootFragmentAdapter(FragmentManager supportFragmentManager, List<String> promoCategoryList) {
        super(supportFragmentManager);
        this.promoCategories=promoCategoryList;
    }

    @Override
    public Fragment getItem(int position) {
        return MessageChildFragment.newInstance(promoCategories.get(position));
    }

    @Override
    public int getCount() {
        return promoCategories.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return promoCategories.get(position);
    }

    @Override
    public void restoreState(Parcelable state, ClassLoader loader) {
        // super.restoreState(state, loader);
        //重写这个方法是为了防止在restoreState的时候导致应用崩溃，这样做虽然不太好，但是目前我也只能想到这种方法了
        Log.i(TAG, "restoreState");
    }
}
